package controllers;

import java.util.List;

import models.Sale;
import models.Trade;
import models.TradeProductList;
import play.mvc.Controller;

public class Types extends Controller {

	static final int pageSize = 3;

	public static void index() {
		render();
	}
	
	/**
	 * 求购分类查询
	 * 
	 * @param typeID
	 * @param pageNum
	 */
	public static void typeTradeList(long typeID, int pageNum) {

		List<TradeProductList> tradeProductList = TradeProductList.getTrade(pageNum, pageSize, typeID);
		long typesCount = TradeProductList.getTypesCount(typeID);

		renderArgs.put("pageSize", pageSize);// 每页显示多少个数据
		renderArgs.put("typesCount", typesCount);// 总数据大小
		renderArgs.put("typeID", typeID);
		renderArgs.put("pageNum", pageNum);

		renderArgs.put("tradeProductList", tradeProductList);// 每页显示的数据

		render();
	}
	

	/**
	 * 出售分类查询
	 * 
	 * @param typeID
	 * @param pageNum
	 */
	public static void typeSaleList(long typeID, int pageNum) {

		List<Sale> saleList = Sale.getSales(pageNum, pageSize, typeID);
		long typesCount = Sale.getTypesCount(typeID);

		renderArgs.put("pageSize", pageSize);// 每页显示多少个数据
		renderArgs.put("typesCount", typesCount);// 总数据大小
		renderArgs.put("typeID", typeID);
		renderArgs.put("pageNum", pageNum);

		renderArgs.put("saleList", saleList);// 每页显示的数据

		render();
	}

	/**
	 * 销售信息分类列表
	 */
	public static void saleCatalogList() {

		List<models.Types> allTypes = models.Types.getSaleAllTypes();

		render(allTypes);
	}

	/**
	 * 求购信息分类列表
	 */
	public static void tradecatalogList() {

		List<models.Types> allTypes = models.Types.getTradeAllTypes();

		render(allTypes);

	}

}
